package com.yinhe.controller.jibeiSync;

import com.yinhe.model.SOCPO;
import com.yinhe.service.jibeiSync.IJiBeiMTParseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author lilei
 * @create 2025-01-25-2025/1/25
 */
@RestController
@Slf4j
@RequestMapping("/dataByInterface")
@Api(tags = "冀北-安分-接口解析数据（直接通过读取文件获取）")
public class JibeiInterfaceController {

    @Autowired
    private IJiBeiMTParseService jiBeiMTParseService;

    @ApiOperation("冀北储能SOC接口解析")
    @RequestMapping(value = "/getSOC", produces = "application/json; charset=utf-8", method = RequestMethod.POST)
    public List<SOCPO> getSOC(@RequestBody Map<String,String> map) throws Exception {
        log.info("获取-冀北储能SOC接口解析,PARAMS:{}",map);
        List<SOCPO> jbpos = new ArrayList<>();
        try {
            String ids = map.get("ids");
            jbpos = jiBeiMTParseService.getSOC(ids);
        } catch (Exception e) {
            log.error("冀北储能SOC接口解析失败：原因如下：" + e.getMessage(),e);
            throw new Exception("冀北储能SOC接口解析失败");
        }
        log.info("获取-冀北储能SOC接口解析成功,返回数据");
        return jbpos;
    }

}
